package com.hejjon.core.utils;

import com.hejjon.core.bean.TreeNode;

import java.util.Arrays;
import java.util.List;

/**
 * @author: cs
 * @date: 2025-02-26 15:39:53
 * @since: 1.0
 */
public class Test {


    public static void main(String[] args) {


        // 创建一些树节点
        TreeNode<Integer> node1 = new TreeNode<>(1, null);
        TreeNode<Integer> node2 = new TreeNode<>(2, 1);
        TreeNode<Integer> node3 = new TreeNode<>(3, 1);
        TreeNode<Integer> node4 = new TreeNode<>(4, 2);
        TreeNode<Integer> node5 = new TreeNode<>(5, 2);
        TreeNode<Integer> node6 = new TreeNode<>(6, 3);
        TreeNode<Integer> node7 = new TreeNode<>(7, null);
        TreeNode<Integer> node8 = new TreeNode<>(8, 7);





        // 将节点放入列表中
        List<TreeNode<Integer>> nodes = Arrays.asList(node1, node2, node3, node4, node5, node6, node7, node8);

        // 使用TreeBuilder组装树形结构
        TreeBuilder<Integer> treeBuilder = new TreeBuilder<>();
        List<TreeNode<Integer>> tree = treeBuilder.buildTree(nodes);


        System.out.println(tree);

    }


}
